package net.go176.backpack;

import java.io.IOException;
import java.util.logging.Level;

import net.go176.backpack.command.CommandManager;
import net.go176.backpack.config.ConfigManager;
import net.go176.backpack.core.CoreHelper;
import net.go176.backpack.core.DataManager;
import net.go176.backpack.core.DataType;
import net.go176.backpack.listener.GUIListener;
import net.go176.backpack.util.simplenbt.Reflector;
import net.go176.backpack.listener.DataHandleListener;
import net.go176.backpack.util.NMSUtil;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public class Backpack extends JavaPlugin {
    private ConfigManager cfgMan = null;
    private DataManager dataMan = null;
    private CoreHelper coreHelper = null;


    public void onEnable() {
        this.cfgMan = new ConfigManager(this);
        this.dataMan = new DataManager(this);
        this.coreHelper = new CoreHelper(this);
        try {
            Reflector.initReflector(this.coreHelper.obcVersion, this.coreHelper.isMCPServer);
            NMSUtil.init(this.coreHelper.obcVersion, this.coreHelper.getExpectedCore(), this.coreHelper.isMCPServer);
        } catch (Throwable t) {
            getLogger().log(Level.SEVERE, "Error initializing core utils", t);
            getPluginLoader().disablePlugin((Plugin)this);
            return;
        }
        this.coreHelper.initCore();
        if (this.coreHelper.isMCPServer) {
            byte b; int i; DataType[] arrayOfDataType; for (i = (arrayOfDataType = DataType.values()).length, b = 0; b < i; ) { DataType type = arrayOfDataType[b];
                if (type != DataType.VANILLA)

                    try {
                        CoreHelper.ModFinder finder = this.cfgMan.isForcedModeEnabled(type) ? this.coreHelper.initCoreEx(type, this.cfgMan.getForcedMode(type)) : this.coreHelper.initCoreEx(type);
                        getLogger().info("Found mod " + type.name + ", version: " + finder.modVersion);
                    } catch (Exception exception) {}  b++; }

        }
        this.coreHelper.setupAccessorGroup();

        PluginManager pm = getServer().getPluginManager();
        pm.registerEvents((Listener)new DataHandleListener(this), (Plugin)this);
        pm.registerEvents((Listener)new GUIListener(this), (Plugin)this);
        getLogger().info("Backpack Enabled!");
        CommandManager.sendMsg((CommandSender)getServer().getConsoleSender(), "&bMyBackpack - Developed by SaraLab");
    }



    public void onDisable() {
        getServer().getScheduler().cancelTasks((Plugin)this);
        this.dataMan.saveAllPlayerData();
        this.dataMan.saveOfflineInvs();
        this.cfgMan.saveAllLogoutWorlds();
        getLogger().info("Backpack Disabled!");
    }

    public ConfigManager getConfigManager() {
        return this.cfgMan;
    }

    public DataManager getDataManager() {
        return this.dataMan;
    }

    public CoreHelper getCoreHelper() {
        return this.coreHelper;
    }
}


/* Location:              D:\User\Xuan\Downloads\MyBackpack1.2.5.jar!\net\saralab\mybackpack\Backpack.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.1.3
 */